/*
 * Filename CheckFactory.java 2022年03月05日
 * Copyright © Ehome Co.Ltd. All Rgiths Reserved.
 * @author wuyingchao
 */
package com.ehome.poct.core.application;

import com.ehome.exception.BizException;
import com.ehome.poct.core.api.virtual.CheckService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * 检测工厂类
 *
 * @author wyc
 * @since 2022/03/05 09:30
 **/
@Component
public class CheckFactory {
    @Autowired private Map<String, CheckService> checkServiceMap;

    private String typeToName(Integer deviceType) {
        switch (deviceType) {
            case 1: return "goldCheckServiceImpl";
            case 2: return "cellCheckServiceImpl";
            default: throw new BizException(111, "不支持的设备类型:" + deviceType);
        }
    }

    public CheckService get(Integer deviceType) {
        return checkServiceMap.get(typeToName(deviceType));
    }
}